<?php

namespace App\Http\Controllers\Admin;

use App\AdminUser;
use Illuminate\Http\Request;
use App\Http\Controllers\api\Controller;
use Illuminate\Support\Facades\Hash;

class AdminController extends Base
{
    public function login(Request $request)
    {
        if ($request->isMethod('post')){
            $map = $request->input();
            $map['password'] = Hash::check('plain-text', $map['password']);

            $adminuser = AdminUser::where('username',$map['username'])
                ->where('password',$map['password'])
                ->get();
            if ($adminuser->isEmpty()){
                return 400;
            }else{
                session(['adminuser'=>$adminuser]);
                return 200;
            }
        }

    }
}
